// Updating a text-file by using a temporary file
import java.io.*;
import java.util.Scanner;
public class UpdateCharacter{
   public static void main(String[] args)throws IOException{
       File infile = new File("input2.txt");    //1. connect an existing input file to a scanner
       Scanner sc = new Scanner(infile);        //

       File outfile = new File("output2.txt");  // 2. create a new output file
       outfile.createNewFile();                 //

       PrintWriter pwriter = new PrintWriter(outfile); //3. wrap the output stream to a PrintWriter

       char ch = sc.nextLine().charAt(0);  // 4. Read from the input file
       ch++;                               // 5. Make the required modifications

       pwriter.print(ch);                  // 6. Write the modifications to the output file

       pwriter.close();                    // 7. close the writer and the scanner
       sc.close();                         //
       infile.delete();                    // 8. delete the input file
       outfile.renameTo(infile);           // 9. rename the output file as the input file

       System.out.println("The file input2.txt has been updated . . .");
   }
}